<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>My notes</title>
<link rel="shortcut icon" href="__TMPL__Public/images/icon.png" />
<link type="text/css" rel="stylesheet" href="__TMPL__Public/css/common.css" media="all" />
<link type="text/css" rel="stylesheet" href="__TMPL__Group/css/groupPage.css" media="all" />

<link type="text/css" rel="stylesheet" href="__TMPL__Public/jquery/css/le-frog/jquery-ui-1.8.16.custom.css" media="all"  />
<script type="text/javascript" src="__TMPL__Public/jquery/js/jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="__TMPL__Public/jquery/js/jquery-ui-1.8.16.custom.min.js"></script>

<script type="text/javascript" src="__TMPL__Public/js/common.js"></script>
<script type="text/javascript" src="__TMPL__Group/js/group.js"></script>
<script type="text/javascript">
	
	$(function(){
		$(".delete_member_button").bind('click', deleteMember);
		$(".add_member_button").bind('click', addFriend);
		$(".buttons").button().css("font-size", "14px");
	});
	

	function deleteMember() {
		var member_id = $(this).attr('member_id');
		var group_id = $(this).attr('group_id');
		var that = this;
		$.get(APP_PATH + "Group/deleteMember", {
			member_id : member_id,
			group_id : group_id
		}, function(result) {
			result = JSON.parse(result);
			if(result.status == 1) {
				alert("已删除");
				var tr = $(that).parent().parent();
				tr.remove();
			}
		});
	}
	
	function addFriend() {
		var user_id = $(this).attr('member_id');
		$.get(APP_PATH + "Friend/add", {
			friend_id : user_id
		}, function(result) {
			result = JSON.parse(result);
			if(result.status == 1) {
				alert("添加好友成功");
				
			}
		});
	}
</script>

</head>
<body id="group_item">
	<include file="Public:header"/>
	
	<div id="main_panel">
		<p><span class="font_style1">小组名称: </span>{$group.name}</p>
		<p><span class="font_style1" >创建者: </span>{$group.founder.name}</p>
		<p><span class="font_style1">简介: </span>{$group.introduction}</p>
		
		<h2>成员列表</h2>
		<table>
			<volist name="group.members" id="member"> 
				<tr>
					<td><span class="font_style1">{$member.name}</span></td>
						<td>
							<neq name="member.id" value="$_SESSION['user']['id']">
								<in name="member.id" value="$user.friend_ids">
									<p>已经是好友</p>
								<else/>
									<input type="button" value="加为好友" member_id="{$member.id}"
	            					 class="add_member_button buttons"/>
								</in>
							</neq>
						</td>
						<eq name="group.founder_id" value="$_SESSION['user']['id']">
							<td>
								<neq name="member.id" value="$_SESSION['user']['id']">
									<input type="button" value="删除该成员" member_id="{$member.id}"
		                               group_id="{$group.id}" class="delete_member_button buttons"/>
								</neq>
							</td>
					</eq>
				</tr>
			</volist> 
		</table>
		
		<h2>图书列表</h2>
		<volist name="books" id="book"> 
			<div class="each_book">
				<img src="{&UPLOAD_FILE_PATH_VIEW}{$book.picture}"  width="220px"/>
				<p>书名：{$book.title}</p>
				<p>所属小组：{$book.group.name}</p>
				<a href="__APP__/Book/showOneBook?book_id={$book.id}">详细</a>
			</div>
		</volist>
	    
		<a id="add_book" class="buttons" href="__APP__/Book/addBookPage?group_id={$group.id}">添加图书</a>
	</div>
<include file="Public:common"/>
</body>
</html>